#ifndef UTILITIES_H
#define UTILITIES_H

#include <QList>
#include <QPoint>
#include <QImage>
#include <QDataStream>
#include <QMap>
#include <QString>

#define MAX_RANGE 99999999.9
#define MAX_UNIT_SPEED 9
#define UNIT_SIZE_THRESHOLD 4.0

typedef QList<QPoint> PathType;
typedef QMap<QString, PathType> PathListType;

enum ENTITY_TYPE
{
   ENTITY_NONE = 0,
   ENTITY_UNIT,
   ENTITY_TOWER,
   ENTITY_UNITEMITTER,
   ENTITY_ANY
};

enum TOWER_KIND_TYPE
{
   TOWER_NONE = 0,
   TOWER_BEAM,
   //TOWER_PROJECTILE
   TOWER_END
};

enum NET_MESSAGE_TYPE
{
   NET_MSG_JOIN = 0,
   NET_MSG_LEAVE,
   NET_MSG_CHAT,
   NET_MSG_GAME_EVENT,
   NET_MSG_USER_EVENT
};

enum EVENT_TYPE
{
   EVENT_GAME_MAPCHANGE = 1,
   EVENT_USER_READY,
   EVENT_USER_ATTACK,
   EVENT_ENTITY_UPDATES,
   EVENT_ENTITY_ADD,
   EVENT_ENTITY_SQUAD_ADD,
   EVENT_ENTITY_SQUAD_ADD_TO_EMITTER,
   EVENT_ENTITY_SQUAD_ID_REQ,
   EVENT_ENTITY_SQUAD_REMOVE,
   EVENT_ENTITY_SQUAD_REMOVE_FROM_EMITTER,
   EVENT_ENTITY_REMOVE,
   EVENT_ENTITY_MODIFY,
   EVENT_ENTITY_ATTACK
};

enum FX_TYPE
{
   FX_NONE = 0,
   FX_TOWER_BEAM_FIRE,
   FX_UNIT_DEATH,
   FX_DAMAGE_TEXT
};

struct EntityBaseStats
{
   ENTITY_TYPE type;
   qint32 kind;
   qint32 size;
   QRgb color;

   //bool operator== (const EntityBaseStats& other) const
   //{
   //   return (type == other.type && kind == other.kind && size == other.size && color == other.color);
   //}
};

struct EntitySquadType
{
   quint32 id;
   quint32 playerID;
   EntityBaseStats stats;
   quint32 cost;
   quint32 size;
   bool isDeployed;
};


/*
enum PIXEL_DIRECTION_TYPE
{
   PIXEL_DIR_NONE,
   PIXEL_DIR_UP,
   PIXEL_DIR_DOWN,
   PIXEL_DIR_LEFT,
   PIXEL_DIR_RIGHT,
   PIXEL_DIR_UPLEFT,
   PIXEL_DIR_UPRIGHT,
   PIXEL_DIR_DOWNLEFT,
   PIXEL_DIR_DOWNRIGHT
};

PathType gGetPath(const QString &filename);

class Event
{
public:
   Event(EVENT_TYPE type);
   virtual void dataStream(QDataStream &data) = 0;
   EVENT_TYPE type();
protected:
   EVENT_TYPE mType;
};

typedef QList<Event*> EventListType;

class EventEntityAttack : public Event
{
public:
   EventEntityAttack(const qint32 attacker, const qint32 target);
   virtual void dataStream(QDataStream &data);
protected:
   qint32 mAttacker;
   qint32 mTarget;
};

class EventEntityRemove : public Event
{
public:
   EventEntityRemove(const qint32 id);
   virtual void dataStream(QDataStream &data);
protected:
   qint32 mId;
};

class EventMapChange : public Event
{
public:
   EventMapChange(const QString &mapFile);
   virtual void dataStream(QDataStream &data);
protected:
   QString mMapFile;
};

class EventEntityModify: public Event
{
public:
   EventEntityModify(const QString &attribute, const QString &value);
   virtual void dataStream(QDataStream &data);
protected:
   QString mAttribute;
   QString mValue;
};
*/

#endif // UTILITIES_H
